package info.cemu.cemu.input

import android.view.KeyEvent
import android.view.MotionEvent

sealed interface InputMapping

enum class ButtonInputMapping(val keyCode: Int) : InputMapping {
    BUTTON_1(KeyEvent.KEYCODE_BUTTON_1),
    BUTTON_2(KeyEvent.KEYCODE_BUTTON_2),
    BUTTON_3(KeyEvent.KEYCODE_BUTTON_3),
    BUTTON_4(KeyEvent.KEYCODE_BUTTON_4),
    BUTTON_5(KeyEvent.KEYCODE_BUTTON_5),
    BUTTON_6(KeyEvent.KEYCODE_BUTTON_6),
    BUTTON_7(KeyEvent.KEYCODE_BUTTON_7),
    BUTTON_8(KeyEvent.KEYCODE_BUTTON_8),
    BUTTON_9(KeyEvent.KEYCODE_BUTTON_9),
    BUTTON_10(KeyEvent.KEYCODE_BUTTON_10),
    BUTTON_11(KeyEvent.KEYCODE_BUTTON_11),
    BUTTON_12(KeyEvent.KEYCODE_BUTTON_12),
    BUTTON_13(KeyEvent.KEYCODE_BUTTON_13),
    BUTTON_14(KeyEvent.KEYCODE_BUTTON_14),
    BUTTON_15(KeyEvent.KEYCODE_BUTTON_15),
    BUTTON_16(KeyEvent.KEYCODE_BUTTON_16),
    BUTTON_A(KeyEvent.KEYCODE_BUTTON_A),
    BUTTON_B(KeyEvent.KEYCODE_BUTTON_B),
    BUTTON_C(KeyEvent.KEYCODE_BUTTON_C),
    BUTTON_L1(KeyEvent.KEYCODE_BUTTON_L1),
    BUTTON_L2(KeyEvent.KEYCODE_BUTTON_L2),
    BUTTON_MODE(KeyEvent.KEYCODE_BUTTON_MODE),
    BUTTON_R1(KeyEvent.KEYCODE_BUTTON_R1),
    BUTTON_R2(KeyEvent.KEYCODE_BUTTON_R2),
    BUTTON_SELECT(KeyEvent.KEYCODE_BUTTON_SELECT),
    BUTTON_START(KeyEvent.KEYCODE_BUTTON_START),
    BUTTON_THUMBL(KeyEvent.KEYCODE_BUTTON_THUMBL),
    BUTTON_THUMBR(KeyEvent.KEYCODE_BUTTON_THUMBR),
    BUTTON_X(KeyEvent.KEYCODE_BUTTON_X),
    BUTTON_Y(KeyEvent.KEYCODE_BUTTON_Y),
    BUTTON_Z(KeyEvent.KEYCODE_BUTTON_Z),
    DPAD_DOWN(KeyEvent.KEYCODE_DPAD_DOWN),
    DPAD_LEFT(KeyEvent.KEYCODE_DPAD_LEFT),
    DPAD_RIGHT(KeyEvent.KEYCODE_DPAD_RIGHT),
    DPAD_UP(KeyEvent.KEYCODE_DPAD_UP),
}

val FALLBACK_BUTTONS = arrayOf(
    ButtonInputMapping.BUTTON_1,
    ButtonInputMapping.BUTTON_2,
    ButtonInputMapping.BUTTON_3,
    ButtonInputMapping.BUTTON_4,
    ButtonInputMapping.BUTTON_5,
    ButtonInputMapping.BUTTON_6,
    ButtonInputMapping.BUTTON_7,
    ButtonInputMapping.BUTTON_8,
    ButtonInputMapping.BUTTON_9,
    ButtonInputMapping.BUTTON_10,
    ButtonInputMapping.BUTTON_11,
    ButtonInputMapping.BUTTON_12,
    ButtonInputMapping.BUTTON_13,
    ButtonInputMapping.BUTTON_14,
    ButtonInputMapping.BUTTON_15,
    ButtonInputMapping.BUTTON_16,
)

enum class AxisInputMapping(val axisCode: Int, val isPositive: Boolean) : InputMapping {
    HAT_X_POS(MotionEvent.AXIS_HAT_X, true),
    HAT_X_NEG(MotionEvent.AXIS_HAT_X, false),
    HAT_Y_POS(MotionEvent.AXIS_HAT_Y, true),
    HAT_Y_NEG(MotionEvent.AXIS_HAT_Y, false),
    RX_POS(MotionEvent.AXIS_RX, true),
    RX_NEG(MotionEvent.AXIS_RX, false),
    RY_POS(MotionEvent.AXIS_RY, true),
    RY_NEG(MotionEvent.AXIS_RY, false),
    RZ_POS(MotionEvent.AXIS_RZ, true),
    RZ_NEG(MotionEvent.AXIS_RZ, false),
    LTRIGGER(MotionEvent.AXIS_LTRIGGER, true),
    RTRIGGER(MotionEvent.AXIS_RTRIGGER, true),
    X_POS(MotionEvent.AXIS_X, true),
    X_NEG(MotionEvent.AXIS_X, false),
    Y_POS(MotionEvent.AXIS_Y, true),
    Y_NEG(MotionEvent.AXIS_Y, false),
    Z_POS(MotionEvent.AXIS_Z, true),
    Z_NEG(MotionEvent.AXIS_Z, false),
}
